#!/bin/bash
set -e

echo "测试dip6 deb包安装和运行..."

# 1. 安装deb包
echo "1. 安装deb包..."
sudo dpkg -i dip6_1.0.0_amd64.deb

# 2. 检查服务状态
echo "2. 检查服务状态..."
sudo systemctl status dip6 --no-pager

# 3. 启动服务
echo "3. 启动服务..."
sudo systemctl start dip6

# 4. 检查服务是否运行
echo "4. 检查服务是否运行..."
sudo systemctl status dip6 --no-pager

# 5. 检查日志
echo "5. 检查日志文件..."
sleep 2
if [ -f /var/log/dip6.log ]; then
    echo "日志文件内容:"
    tail -5 /var/log/dip6.log
else
    echo "日志文件不存在"
fi

# 6. 停止服务
echo "6. 停止服务..."
sudo systemctl stop dip6

echo "测试完成！"
echo ""
echo "管理命令:"
echo "  启动: sudo systemctl start dip6"
echo "  停止: sudo systemctl stop dip6"
echo "  状态: sudo systemctl status dip6"
echo "  日志: tail -f /var/log/dip6.log"
echo "  卸载: sudo dpkg -r dip6"
